package com.wc.alorithm_luogu._贪心.P1106_删数问题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/18 10:20
 * @description https://www.luogu.com.cn/problem/P1106
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 266;
    static char[] a = new char[N];
    static boolean[] vis = new boolean[N];
    static int n, k;

    // 思路参考：https://www.luogu.com.cn/article/3hh0vlkn
    // 相当于选择n - k个数输出
    public static void main(String[] args) {
        a = ('0' + sc.next() + '0').toCharArray();
        n = a.length - 2;
        k = sc.nextInt();
        // 一共要输出的数
        int rest = n - k;
        // 已经输出的数
        int cnt = 0;
        int t = 1;
        // 是否是前导0
        boolean flg = false;
        while (cnt < rest) {
            int minp = t;
            for (int i = t; i <= t + k; i++) {
                if (a[minp] > a[i]) minp = i;
            }
            if (a[minp] != '0') flg = true;
            if (flg) out.print(a[minp]);
            k -= minp - t;
            t = minp + 1;
            cnt++;
        }
        // 全是前导0，就没有数
        if (!flg) out.print(0);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}